package ai.assist.admin.dto;

import ai.assist.common.utils.DateUtilsEx;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
 * @author hui
 * @Date 2024/7/16 22:52
 **/
@Data
@ApiModel
public class DateRangeDTO {

    @ApiModelProperty("开始时间")
    private List<String> dateRange;

    @ApiModelProperty(hidden = true)
    private Date startTime;

    @ApiModelProperty(hidden = true)
    private Date endTime;

    public Date getStartTime() {
        if (dateRange != null && !dateRange.isEmpty()) {
            return DateUtilsEx.getDayStart(DateUtilsEx.parseDayByDay(dateRange.get(0)));
        }
        return startTime;
    }

    public Date getEndTime() {
        if (dateRange != null && !dateRange.isEmpty() && dateRange.size() == 2) {
            return DateUtilsEx.getDayEnd(DateUtilsEx.parseDayByDay(dateRange.get(1)));
        }
        return endTime;
    }

}
